//package com.yunhe.authority.controller.base;
//
//import com.yunhe.common.model.PageParam;
//import com.yunhe.authority.domain.base.Theme;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.DomainList;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.authority.service.base.ThemeService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.Optional;
//
///**
// * 主题Controller
// * @author liuronglei
// * @desc 主题控制类定义
// */
//@Api(value = "theme", description = "主题维护", tags = {"Base_Theme"})
//@RestController
//@RequestMapping("/themes")
//public class ThemeController {
//    @Autowired
//    private ThemeService themeService;
//
//    /**
//     * 新增主题
//     * @param theme 主题对象
//     */
//    @ApiOperation("新增主题")
//
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody Theme theme)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        Theme newTheme = themeService.createTheme(theme);
//        return new ResponseEntity<>(new ResultObject<>(newTheme), HttpStatus.OK);
//    }
//
//    /**
//     * 批量新增主题
//     * @param domainList 主题对象列表
//     */
//    @ApiOperation("批量新增主题")
//
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(
//            @RequestBody DomainList<Theme> domainList)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        Iterable<Theme> newThemes = themeService.createTheme(domainList.getList());
//        return new ResponseEntity<>(new ResultObject<>(newThemes), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除主题
//     * @param id id
//     */
//    @ApiOperation("根据ID删除主题")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "主题ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(
//            @PathVariable("id") Long id) {
//        themeService.deleteTheme(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 根据主题代码删除主题
//     * @param code 主题代码
//     */
//    @ApiOperation("根据主题代码删除主题")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "主题代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/code/{code}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> deleteByCode(
//            @PathVariable("code") Long code) {
//        Long result = themeService.deleteThemeByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    /**
//     * 根据主题编号删除主题
//     * @param name 主题编号
//     */
//    @ApiOperation("根据主题编号删除主题")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "name", value = "主题编号", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/name/{name}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> deleteByName(
//            @PathVariable("name") String name) {
//        Long result = themeService.deleteThemeByName(name);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    /**
//     * 更新主题（更新全部字段）
//     * @param id ID
//     * @param theme 主题对象
//     */
//    @ApiOperation("更新主题（更新全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(
//            @PathVariable("id") Long id,
//            @RequestBody Theme theme)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException {
//        theme.setId(id);
//        Theme newTheme = themeService.updateTheme(theme);
//        return new ResponseEntity<>(new ResultObject<>(newTheme), HttpStatus.OK);
//    }
//
//    /**
//     * 更新主题（更新指定字段）
//     * @param code 主题代码
//     * @param name 主题编号
//     * @param title 主题标题
//     */
//    @ApiOperation("更新主题（更新指定字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "主题代码", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "主题编号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "主题标题", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(
//            @PathVariable("id") Long id,
//            @RequestParam("code") Optional<Long> code,
//            @RequestParam("name") Optional<String> name,
//            @RequestParam("title") Optional<String> title)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        Theme newTheme = themeService.updateTheme(id, code.orElse(null), name.orElse(null), title.orElse(null));
//        return new ResponseEntity<>(new ResultObject<>(newTheme), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID获得主题对象
//     * @param id ID
//     */
//    @ApiOperation("根据ID获得主题对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "主题ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(
//            @PathVariable("id") Long id) {
//        Theme Theme = themeService.findByThemeId(id);
//        return new ResponseEntity<>(new ResultObject<>(Theme), HttpStatus.OK);
//    }
//
//    /**
//     * 根据主题代码获得主题对象
//     * @param code 主题代码
//     */
//    @ApiOperation("根据主题代码获得主题对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "主题代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/code/{code}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByCode(
//            @PathVariable("code") Long code) {
//        Theme theme = themeService.findByCode(code);
//        return new ResponseEntity<>(new ResultObject<>(theme), HttpStatus.OK);
//    }
//
//    /**
//     * 根据主题编号获得主题对象
//     * @param name 主题编号
//     */
//    @ApiOperation("根据主题编号获得主题对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "name", value = "主题编号", required = true, dataType = "string", paramType = "path")
//    })
//    @RequestMapping(value = "/name/{name}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByName(
//            @PathVariable("name") String name) {
//        Theme Theme = themeService.findByName(name);
//        return new ResponseEntity<>(new ResultObject<>(Theme), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得主题列表
//     */
//    @ApiOperation("根据条件获得主题列表")
//
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(
//            @ModelAttribute PageParam pageParam) {
//        Iterable<Theme> results = themeService.findThemes(pageParam);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//}
